@extends('layouts.back_stage')
@section('content')
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/swiper.min.css"/>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/swiper.min.js"></script>
    <style>
        /*描述*/
        .fL{margin-left:50px;}
        .desImg{width:100%;height:auto;float:left;}
        .desImg img{width:50px;height:50px;margin-right:10px;border:1px solid #ccc;float:left;cursor:pointer;}
        /*聊天*/
        .chats{width:72%;float:left;height:auto;background:#fff;}
        .qqBox{width:100%;height: 600px;background:#fff;display: -webkit-box;-webkit-box-orient: vertical;}
        .context{-webkit-box-flex: 1;display: -webkit-box;-webkit-box-orient: horizontal;}
        .conRight{-webkit-box-flex: 1;display: -webkit-box;-webkit-box-orient: vertical;}
        .RightCont{-webkit-box-flex: 1;overflow-y: scroll;margin-bottom: 10px;}
        .RightCont::-webkit-scrollbar{width: 0px;}
        .RightCont ul{list-style: none;margin: 0;padding: 0;}
        .RightCont li{width: 100%;height: auto;min-height:66px;display:inline-block;color:#666;}
        .nesHead{width:96%;height:20px;margin:5px 2%;font-size: 14px;}
        .nesHead .neInfo{width:40%;float:left;height:20px;margin:0;}
        .nesHead .neInf{width:60%;float:right;height:20px;margin:0;text-align:end;}
        .news{width:96%;height:auto;margin:10px 2%;font-size: 14px;min-height: 20px;}
        .lineBg{width:96%;margin:0 2%;height:1px;background:url("{{env('CDN_DOMAIN_NAME')}}/img/dottedLine.png") bottom left repeat;background-size:15px 1px;}
        .RightFoot{width: 100%;height: 128px;border-top: 1px solid #ccc;position: relative;}
        .sendBtn{width:68px;height:25px;line-height:25px;background:#0188fb;border:none;outline:none;position: absolute;bottom:10px;right:10px;color:white;}
        .ChatRecord{width: 100%;height: 20px;text-align: center;font-size: 12px;color: deepskyblue;cursor: pointer;display: none;}
        /*右上进度*/
        .operate{width:25%;height:auto;float:right;}
        .tDiv{width:100%;background:#fff;padding:30px;height:auto;}
        .ope_ul,.ope_li,.ope_dl{width:100%;height:auto;}
        .ope_dl{margin-bottom:0;}
        .ope_dt{width: 100%;height: 20px;font-size: 14px;line-height: 20px;}
        .ope_dt .bgSp{width:23px;height:20px;float:left;background:url("{{env('CDN_DOMAIN_NAME')}}/img/bgGrey.png") no-repeat center center;}
        .ope_dt .bgSp.on{background:url("{{env('CDN_DOMAIN_NAME')}}/img/bgBlue.png") no-repeat center center;}
        .ope_dt .bgSp.bg{background:url("{{env('CDN_DOMAIN_NAME')}}/img/bigBlue.png") no-repeat center center;}
        .ope_dd{width:1px;height:25px;background:#ccc;margin:5px 11px;}
        .ope_dd.in{background:#337ab7;}
        /*右下进度*/
        .Bdiv{width:100%;background:#fff;padding:30px;height:auto;margin-top:30px;}
        .btn_ol,.btn_li{width:100%;height:auto;}
        .btns_a{width:100%;height:35px;line-height:35px;text-align:center;color:#fff;background:#c5c5c5;font-size:15px;display:inline-block;margin-top:15px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;pointer-events:none;}
        .btns_a:hover, .btns_a:focus{color:#fff;}
        .btns_a.ar{background:#337ab7;pointer-events:auto;}
        .as7{width:42%;float:left;}
        .as9{width:42%;float:right;}
        .fillout{display:none;}
        .refeA{width:22%;height:35px;line-height:35px;text-align:center;color:#fff;background: #337ab7;font-size:15px;display:inline-block;margin-top:15px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;}
        .refeA:hover, .refeA:focus{color:#fff;}
        .couN{width:76%;padding:0 2%;height: 35px;line-height: 35px;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;outline:none;border:1px solid #ccc;}
        /*轮播*/
        .swiperDiv{width:60%;height:60%;background:#fff;position:fixed;top:20%;left:20%;z-index:20000;display:none;}
        .swiper-container {width: 100%;height: 100%;}
        .swiper-slide {text-align: center;font-size: 18px;background: #fff;}
        .swiper-pagination-fraction{color:#fff;}
        /*遮罩层*/
        .mask{position:fixed;top:0;right:0;left:0;bottom:0;z-index:10000;background:#000;opacity:0.8;filter:alpha(opacity=80);-moz-user-select: none; -webkit-user-select: none;display:none;}
        /*关闭*/
        .closes{width:35px;height:38px;position:fixed;top:30px;right:30px;z-index:10005;cursor:pointer;display:none;}
        .closes i{width:100%;height:100%;color:#fff;font-size:40px;}
    </style>
    <div class="container" style="margin-bottom:20px;">
        <div style="padding:20px 0;"><h3>工单详情</h3></div>
        <div class="chats">
            <div class="qqBox">
                <div class="context">
                    <div class="conRight">
                        <div class="RightCont">
                            <div class="ChatRecord">查看更多消息</div>
                            <ul class="newsList">
                                <li>
                                    <div class="nesHead"><p class="neInfo">问题描述：</p>
                                        <p class="neInf">{{$pinfos->created_at}}</p>
                                    </div>
                                    <div class="news" style="display:inline-block;">

                                        @if(count($img_infos)>0)
                                        <p>商品款号：
                                            @if(!empty($img_infos[0]->girard))
                                                {{$img_infos[0]->girard}}
                                            @endif
                                        </p>
                                        @endif
                                        <p>
                                            <span>客户姓名：{{$pinfos->customer_name}}</span>
                                            @if(!empty($pinfos->customer_tel))
                                            <span class="fL">联系方式：{{$pinfos->customer_tel}}</span>
                                            @endif
                                        </p>

                                        @if($pinfos->is_send===0 || $pinfos->is_send==1 || !empty($pinfos->express_num))
                                        <p>
                                            @if($pinfos->is_send===0 || $pinfos->is_send==1)
                                            <span>是否寄出：@if($pinfos->is_send===0)未寄出@elseif($pinfos->is_send==1)已寄出@endif</span>
                                            @endif
                                            @if(!empty($pinfos->express_num))
                                            <span class="fL">快递单号：{{$pinfos->express_num}}</span>
                                            @endif
                                        </p>
                                        @endif

                                        @if(count($img_infos)>0)
                                            <p>描述：
                                            @if(!empty($img_infos[0]->description))
                                            {{$img_infos[0]->description}}
                                            @endif
                                            </p>
                                        @endif

                                        @if(!empty($pinfos->proposal))
                                            <p>建议方案：{{$pinfos->proposal}}</p>
                                        @endif

                                        @if(count($img_infos)>0)
                                        <div class="desImg">
                                            @foreach($img_infos as $k => $v)
                                                @if(!empty($v->img_url))
                                                    <img src="{{env('CDN_DOMAIN_NAME')}}/work_order/{{$v->img_url}}">
                                                @endif
                                            @endforeach
                                        </div>
                                        @endif
                                    </div>
                                    <div class="lineBg"></div>
                                </li>
                                @if(count($infos)>0)
                                    @foreach($infos as $k => $v)
                                        <li>
                                            <div class="nesHead"><p class="neInfo">{{$admins[$v->from_uid] or ''}}(@if($v->identity_type==1)销售@elseif($v->identity_type==2)仓库@elseif($v->identity_type==3)财务@else 未知身份@endif)：</p>
                                                <p class="neInf">{{$v->created_at}}</p>
                                            </div>
                                            <div class="news">{{$v->message}}</div>
                                            <div class="lineBg"></div>
                                        </li>
                                    @endforeach
                                @endif
                            </ul>
                        </div>
                        <div class="RightFoot">
                            <div class="inputBox">

                                <textarea id="dope" placeholder="请填写您的回复..." style="width:98%;height:75px;border:none;outline:none;resize:none;margin:10px 1% 0 1%;"></textarea>

                               @if(Auth::guard('admin')->user()->identity_type==1 && (Auth::guard('admin')->user()->id !=$pinfos->from_uid))
                                    <button class="sendBtn" disabled style="background:#c5c5c5;">发送(s)</button>
                                @elseif(Auth::guard('admin')->user()->identity_type==1 && (Auth::guard('admin')->user()->id ==$pinfos->from_uid))
                                    <button class="sendBtn"  abc="{{$pid}}">发送(s)</button>

                                @elseif( Auth::guard('admin')->user()->identity_type==2 && !is_null($pinfos->to_uid) && (Auth::guard('admin')->user()->id !=$pinfos->to_uid))
                                    <button class="sendBtn" disabled style="background:#c5c5c5;">发送(s)</button>

                                @elseif(Auth::guard('admin')->user()->identity_type==2 && Auth::guard('admin')->user()->id ==$pinfos->to_uid)
                                    <button class="sendBtn"  abc="{{$pid}}">发送(s)</button>

                                @elseif(Auth::guard('admin')->user()->identity_type==2 )
                                    <button class="sendBtn"  abc="{{$pid}}">发送(s)</button>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="operate">
            <div class="tDiv">
                <p>处理进度</p>
                <ul class="ope_ul">
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status==1) bg @else on @endif"></span>
                                <span class="opeTxt">提交工单</span>
                            </dt>
                            <dd class="ope_dd @if($pinfos->pro_status>=2) in @endif"></dd>
                        </dl>
                    </li>
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status>=2) on @endif"></span>
                                <span class="opeTxt">接收工单</span>
                            </dt>
                            <dd class="ope_dd @if($pinfos->pro_status>=2) in @endif"></dd>
                        </dl>
                    </li>
                    @if($pinfos->pro_status==2)
                        <li class="ope_li">
                            <dl class="ope_dl">
                                <dt class="ope_dt">
                                    <span class="bgSp bg @if($pinfos->pro_status==2) bg @endif"></span>
                                    <span class="opeTxt">待收货</span>
                                </dt>
                                <dd class="ope_dd "></dd>
                            </dl>
                        </li>
                    @endif
                    @if($pinfos->pro_status>=4)
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status>=4)  on @endif"></span>
                                <span class="opeTxt">确认收货</span>
                            </dt>
                            <dd class="ope_dd @if($pinfos->pro_status>=4) in @endif"></dd>
                        </dl>
                    </li>
                    @endif
                    @if($pinfos->pro_status==4)
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status==4) bg  @endif"></span>
                                <span class="opeTxt">质检中</span>
                            </dt>
                            <dd class="ope_dd @if($pinfos->pro_status>4) in @endif"></dd>
                        </dl>
                    </li>
                    @endif
                    @if($pinfos->pro_status>=6)
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status==6) bg @else on @endif"></span>
                                <span class="opeTxt">质检完成</span>
                            </dt>
                            <dd class="ope_dd @if($pinfos->pro_status>6) in @endif"></dd>
                        </dl>
                    </li>
                    @endif
                    @if($pinfos->pro_status==9 && $pinfos->deal_type==-1)
                        <li class="ope_li">
                            <dl class="ope_dl">
                                <dt class="ope_dt">
                                    <span class="bgSp @if($pinfos->pro_status==9) bg  @endif"></span>
                                    <span class="opeTxt">退款中</span>
                                </dt>
                                <dd class="ope_dd "></dd>
                            </dl>
                        </li>
                    @endif
                    @if($pinfos->pro_status>=10 && $pinfos->deal_type==-1)
                        <li class="ope_li">
                            <dl class="ope_dl">
                                <dt class="ope_dt">
                                    <span class="bgSp @if($pinfos->pro_status==10) bg @else on @endif"></span>
                                    <span class="opeTxt">已退款</span>
                                </dt>
                                <dd class="ope_dd @if($pinfos->pro_status>10 && $pinfos->deal_type==-1) in @endif"></dd>
                            </dl>
                        </li>
                    @endif
                    @if($pinfos->pro_status==7 && $pinfos->deal_type==1)
                    <li class="ope_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status==7) bg @else on @endif"></span>
                                <span class="opeTxt">换货中</span>
                            </dt>
                            <dd class="ope_dd "></dd>
                        </dl>
                    </li>
                    @endif
                    @if($pinfos->pro_status>=8 && $pinfos->deal_type==1)
                        <li class="ope_li">
                            <dl class="ope_dl">
                                <dt class="ope_dt">
                                    <span class="bgSp @if($pinfos->pro_status==7 || $pinfos->pro_status==8) bg @else on @endif"></span>
                                    <span class="opeTxt">已发货</span>
                                </dt>
                                <dd class="ope_dd @if($pinfos->pro_status>8) in @endif"></dd>
                            </dl>
                        </li>
                    @endif
                    <li class="ope_li over_li">
                        <dl class="ope_dl">
                            <dt class="ope_dt">
                                <span class="bgSp @if($pinfos->pro_status==11 && $pinfos->status==3) bg @else  @endif"></span>
                                <span class="opeTxt">已结单</span>
                            </dt>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="Bdiv">
                <p>员工操作</p>
                <ol class="btn_ol">
                    @if(Auth::guard('admin')->user()->identity_type == 2)

                    <li class="btn_li">
                        <a href="javascript:;" abc="2" id="{{$pid}}" class="btns_a as2 @if($pinfos->pro_status==1) ar @endif">接收工单</a>
                    </li>
                    <li class="btn_li">
                        <a href="javascript:;" abc="4" id="{{$pid}}" class="btns_a as4
                        @if($pinfos->to_uid == Auth::guard('admin')->user()->id)
                            @if( $pinfos->pro_status==2) ar @endif
                        @endif
                                ">确认收货</a>
                    </li>
                    <li class="btn_li">
                        <a href="javascript:;" abc="6" id="{{$pid}}" class="btns_a as6
                         @if($pinfos->to_uid == Auth::guard('admin')->user()->id)
                            @if($pinfos->pro_status==4) ar @endif
                        @endif
                                ">质检完成</a>
                    </li>
                    <li class="btn_li">
                        <a href="javascript:;" abc="7" id="{{$pid}}" class="btns_a as7
                        @if($pinfos->to_uid == Auth::guard('admin')->user()->id)
                        @if($pinfos->pro_status==6) ar @endif
                        @endif
                        ">换货</a>
                        <a href="javascript:;" abc="9" id="{{$pid}}" class="btns_a as9
                        @if($pinfos->to_uid == Auth::guard('admin')->user()->id)
                             @if($pinfos->pro_status==6) ar @endif
                        @endif
                        ">退货</a>
                    </li>

                    <li class="btn_li fillout " style="display: @if($pinfos->pro_status==7 && empty($pinfos->return_express_num)) block @endif">
                        <input type="text" class="couN" value="" placeholder="请填写快递单号" >
                        <a href="javascript:;" class="refeA" abc="{{$pinfos->id}}">提交</a>
                    </li>

                    <li class="btn_li">
                        <a href="javascript:;" abc="8" id="{{$pid}}" class="btns_a as8
                        @if($pinfos->to_uid == Auth::guard('admin')->user()->id)
                            @if($pinfos->pro_status==7 && !empty($pinfos->return_express_num)) ar @endif
                        @endif
                        ">发货完成</a>
                    </li>
                    @else
                    <li class="btn_li">
                        <a href="javascript:;" abc="10" id="{{$pid}}" class="btns_a as10
                        @if($pinfos->from_uid == Auth::guard('admin')->user()->id)
                            @if($pinfos->pro_status==9) ar @endif
                        @endif

                        ">完成退款</a>
                    </li>
                    <li class="btn_li">
                        <a href="javascript:;" abc="11" id="{{$pid}}" class="btns_a as11
                        @if($pinfos->from_uid == Auth::guard('admin')->user()->id)
                            @if(in_array($pinfos->pro_status,[8,10])) ar @endif
                        @endif
                        ">确认结单</a>
                    </li>
                    @endif
                </ol>
            </div>
        </div>
    </div>
    {{--遮罩层--}}
    <div class="mask"></div>
    <div class="closes"><i class="fa fa-times-circle"></i></div>
    <!-- Swiper -->
    <div class="swiperDiv">
        <div class="swiper-container swiper-container-horizontal">
            <div class="swiper-wrapper">
                @if(count($img_infos)>0)
                    @foreach($img_infos as $k => $v)
                    <div class="swiper-slide" style="width: 980px;">
                        <div class='swiper-zoom-container' >
                            <img src="{{env('CDN_DOMAIN_NAME')}}/work_order/{{$v->img_url}}">
                        </div>
                    </div>
                    @endforeach
                @endif
            </div>
            <!-- Add Pagination -->
            <div class="swiper-pagination swiper-pagination-fraction">
                <span class="swiper-pagination-current">1</span> / <span class="swiper-pagination-total">8</span>
            </div>
            <!-- Add Arrows -->
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev swiper-button-disabled"></div>
        </div>
    </div>
    <script>
        /*轮播*/
        var swiper = new Swiper('.swiper-container', {
            nextButton: '.swiper-button-next',
            prevButton: '.swiper-button-prev',
            pagination: '.swiper-pagination',
            paginationType: 'fraction'
        });
        /*点击图片打开*/
        $(".desImg img").click(function () {
            var m=$(this).index();
            swiper.slideTo(m,10, false);
            $(".mask").show();
            $(".swiperDiv").show();
            $(".closes").show();
            swiper.onResize();//刷新swiper

        });
        /*点击关闭*/
        $(".closes").click(function () {
            $(this).hide();
            $(".swiperDiv").hide();
            $(".mask").hide();
        });
        /*进度操作*/
        $(".btns_a").click(function(){
            var that=this;
            var pid=$(this).attr("id");
            var num=$(this).attr("abc");
            var status;
            if(num==2){
                status=2;
            }else if(num==4){
                status=4;
            }else if(num==6){
                status=6;
            }else if(num==7){
                status=7;
            }else if(num==9){
                status=9;
            }else if(num==8){
                status=8;
            }else if(num==10){
                status=10;
            }else if(num==11){
                status=11;
            }
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                url:'/work-order/chat-update-work-order',
                type:'post',
                data:{
                    pid:pid,
                    status:status
                },
                dataType:'json',
                success:function(data){
                    if(data.success) {
                        var id=data.status;
                        $(that).removeClass("ar");
                        if(id==4){
                            $(".as4").addClass("ar");
                            $(".ope_li:nth-of-type(1)").find(".bgSp").removeClass("bg");
                            $(".ope_li:nth-of-type(1)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(1)").find(".ope_dd").addClass("in");

                            $(".ope_li:nth-of-type(2)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(2)").find(".ope_dd").addClass("in");
                            $(".over_li").before('<li class="ope_li"><dl class="ope_dl"><dt class="ope_dt"><span class="bgSp bg"></span><span class="opeTxt">待收货</span></dt><dd class="ope_dd"></dd></dl></li>');
                        }else if(id==6){
                            $(".as6").addClass("ar");
                            $(".ope_li:nth-of-type(3)").find(".bgSp").removeClass("bg");
                            $(".ope_li:nth-of-type(3)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(3)").find(".opeTxt").text("确认收货");
                            $(".ope_li:nth-of-type(3)").find(".ope_dd").addClass("in");
                            $(".over_li").before('<li class="ope_li"><dl class="ope_dl"><dt class="ope_dt"><span class="bgSp bg"></span><span class="opeTxt">质检中</span></dt><dd class="ope_dd"></dd></dl></li>');
                        }else if(id=='7,9'){
                            $(".ope_li:nth-of-type(4)").find(".opeTxt").text("质检完成");
                            var arr=id.split(",");
                            for(var i=0;i<arr.length;i++){
                                $(".as"+arr[i]).addClass("ar");
                            }
                        }else if(id==8){
                            $(".fillout").show();
                            $(".as9").removeClass("ar");
                            $(".ope_li:nth-of-type(4)").find(".bgSp").removeClass("bg");
                            $(".ope_li:nth-of-type(4)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(4)").find(".ope_dd").addClass("in");
                            $(".over_li").before('<li class="ope_li"><dl class="ope_dl"><dt class="ope_dt"><span class="bgSp bg"></span><span class="opeTxt">换货中</span></dt><dd class="ope_dd"></dd></dl></li>');
                        }else if(id==10){
                            $(".as7").removeClass("ar");
                            $(".ope_li:nth-of-type(4)").find(".bgSp").removeClass("bg");
                            $(".ope_li:nth-of-type(4)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(4)").find(".ope_dd").addClass("in");
                            $(".over_li").before('<li class="ope_li"><dl class="ope_dl"><dt class="ope_dt"><span class="bgSp bg"></span><span class="opeTxt">退款中</span></dt><dd class="ope_dd"></dd></dl></li>');
                        }else if(id==11){
                            var other=data.others;
                            if(other==1){
                                $(".ope_li:nth-of-type(5)").find(".opeTxt").text("已发货");
                            }else if(other==2){
                                $(".as11").addClass("ar");
                                $(".ope_li:nth-of-type(5)").find(".opeTxt").text("已退款");
                            }
                        }else if(id==100){
                            $(".ope_li:nth-of-type(5)").find(".bgSp").removeClass("bg");
                            $(".ope_li:nth-of-type(5)").find(".bgSp").addClass("on");
                            $(".ope_li:nth-of-type(5)").find(".ope_dd").addClass("in");
                            $(".ope_li:nth-of-type(6)").find(".bgSp").addClass("bg");
                        }

                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            })
        });
        $(".refeA").click(function(){
            var return_express_num=$(".couN").val();
            var id=$(this).attr("abc");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                url:'/work-order/return-express-num',
                type:'post',
                data:{
                    id:id,
                    return_express_num:return_express_num
                },
                dataType:'json',
                success:function(data){
                    if(data.success) {
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text("提交成功");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        var s2='<li>' +
                                '<div class="nesHead"><p class="neInfo">'+data.seller+'(仓库)：</p>' +
                                    '<p class="neInf">'+data.time+'</p>' +
                                '</div>' +
                                '<div class="news">换货快递单号为：'+return_express_num+'</div>' +
                                '<div class="lineBg"></div>' +
                            '</li>';
                        $(".newsList").append(s2);
                        //将滚动条始终保持在底部
                        $('.RightCont').scrollTop($('.RightCont')[0].scrollHeight );
                        $(".fillout").hide();
                        $(".as8").addClass("ar");
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            })
        });
        /*快递单号英文和数字*/
        $(".couN").bind("input","onpropertychange",function(){
            $(this).val($(this).val().replace(/[^\dA-Za-z]/g,""));

        });
        var path='{{env('CDN_DOMAIN_NAME')}}';
        //发送消息
        $('.sendBtn').on('click',function(){
            var pid=$(this).attr("abc");
            var news=$('#dope').val();
            if(news==''){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("发送内容不能为空");
                $(".oSuccess").show(0).delay(1000).hide(0);
                return false;
            }
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                url:'/work-order/work-order-chat',
                type:'post',
                data:{
                    pid:pid,
                    message: news
                },
                dataType:'json',
                success:function (data) {
                    if(data.success == true){
                        $('#dope').val('');
                        var str='';
                        str+='<li>' +
                            '<div class="nesHead"><p class="neInfo">'+data.msg.admin_name+'('+data.msg.identity_type+')：</p><p class="neInf">'+data.msg.created_at+'</p></div>' +
                            '<div class="news">'+news+'</div>' +
                            '<div class="lineBg"></div>'+
                            '</li>';
                        $('.newsList').append(str);
//                        setTimeout(answers,1000);
                        $('.conLeft').find('li.bg').children('.liRight').children('.infor').text(news);
                        //将滚动条始终保持在底部
                        $('.RightCont').scrollTop($('.RightCont')[0].scrollHeight );

                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        });
        window.onload=function(){
            $("#dope").focus();
            var url = window.location.href;
            if(url.indexOf("tn=1") >= 0 ) {
                $(".order_li").addClass('active').siblings().removeClass('active');
                $(".order_li").children('.nav-second-level').addClass('in').parent().siblings().children('.nav-second-level').removeClass('in');
            }
            var num=$(".order_li.item-li").index();
            sessionStorage.setItem('Number',num);
        };
        //将滚动条始终保持在底部
        $('.RightCont').scrollTop($('.RightCont')[0].scrollHeight );
    </script>
@endsection
